package com.crrc.dataparse.base.exception;

import java.io.Serializable;

public class Error implements Serializable {
    private static final long serialVersionUID = -6314165727053965512L;
    private String rawDataId;
    private short exceptionType;
    private short exceptionNode;
    private boolean isThrowed = false;

    public String getRawDataId() {
        return this.rawDataId;
    }

    public void setRawDataId(String rawDataId) {
        this.rawDataId = rawDataId;
    }

    public ExceptionType getExceptionType() {
        return ExceptionType.values()[this.exceptionType];
    }

    public void setExceptionType(ExceptionType exceptionType) {
        this.exceptionType = (short)exceptionType.ordinal();
    }

    public ExceptionNode getExceptionNode() {
        return ExceptionNode.values()[this.exceptionNode];
    }

    public void setExceptionNode(ExceptionNode node) {
        this.exceptionNode = (short)node.ordinal();
    }

    public boolean isThrowed() {
        return this.isThrowed;
    }

    public void setThrowed(boolean isThrowed) {
        this.isThrowed = isThrowed;
    }

    public Error() {
    }

    public Error(String rawDataId, ExceptionType exceptionType, ExceptionNode exceptionNode, boolean isThrowed) {
        this.rawDataId = rawDataId;
        this.exceptionType = (short)exceptionType.ordinal();
        this.exceptionNode = (short)exceptionNode.ordinal();
        this.isThrowed = isThrowed;
    }

    public Error(ExceptionType exceptionType, ExceptionNode exceptionNode) {
        this.exceptionType = (short)exceptionType.ordinal();
        this.exceptionNode = (short)exceptionNode.ordinal();
    }

    public static enum ExceptionNode {
        PROROCOL_RECOG,
        PARSE,
        DEVICE_RECOG,
        TRANS,
        DATA_STORE;

        private ExceptionNode() {
        }
    }

    public static enum ExceptionType {
        RUN_TIME,
        CHECK_FAIL,
        TREAT_MISSING,
        ITEM_MISSING,
        TREAT_ERROR,
        DEVICE_MISSING,
        UN_KNOWN;

        private ExceptionType() {
        }
    }
}

